-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here

-- 系统剪贴版的设置
vim.opt.clipboard = "unnamedplus"

-- 窗口分隔符的样式
-- vim.opt.fillchars = { stl = "─", horiz = "─", vert = "│" }
-- vim.cmd.hi 'WinSeparator guifg=orange'

vim.g.autoformat = false --取消自动格式化

local function no_paste()
  return function()
    local content = vim.fn.getreg('"')
    return vim.split(content, "\n")
  end
end
-- 用ssh连接时，用osc52剪贴板，可支持从neovim中拷贝内容到本地
if os.getenv("SSH_TTY") ~= nil then
  vim.g.clipboard = {
    name = "OSC 52",
    copy = {
      ["+"] = require("vim.ui.clipboard.osc52").copy("+"),
      ["*"] = require("vim.ui.clipboard.osc52").copy("*"),
    },
    -- 不用系统剪贴板的粘贴功能，因为可能osc52要解析很久，实际使用Ctrl+Shift+V就可以了
    paste = {
      ["+"] = no_paste(),
      ["*"] = no_paste(),
    },
  }
end

-- WSL子系统的剪贴版设置
local is_wsl = vim.fn.has("wsl") == 1
if is_wsl then
  vim.g.clipboard = {
    name = "WslClipboard",
    copy = {
      ["+"] = "clip.exe",
      ["*"] = "clip.exe",
    },
    paste = {
      -- ["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
      -- ["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
      ["+"] = no_paste(),
      ["*"] = no_paste(),
    },
    cache_enabled = 0,
  }
end

-- LSP Server to use for Python.
-- Set to "basedpyright" to use basedpyright instead of pyright.
vim.g.lazyvim_python_lsp = "pyright"
-- Set to "ruff_lsp" to use the old LSP implementation version.
-- vim.g.lazyvim_python_ruff = "ruff"
-- vim.g.python3_host_prog = "/home/tom/miniconda3/envs/preprocess/bin/python3"
